An enthusiastic, adaptive, and fast-learning person with a broad and acute interest in the discovery of new innovative drugs, I particularly enjoy collaborating with scientists from different disciplines to develop new skills and solve new challenges.
The Intersect method or operator is used to combine multiple collections or lists into a single collection or list and return common elements from both collections.
Syntax
var result = collection.Intersect(collection2);
Example
using System; using System.Collections.Generic; using System.Linq;
public class Program { public static void Main() { List<string> count1= new List<string>() { 'UK', 'Australia', 'India', 'USA' }; List<string> count2 = new List<string>() { 'India', 'UAE', 'Canada', 'UK', 'China', 'Pok' };
List<string> list = count1.Intersect(count2).ToList(); list.ForEach( country => Console.WriteLine(country) );
Console.ReadLine(); } }
Output
UK
India
Liked By
Write Answer
How to find common data from two list in LINQ?
Join MindStick Community
You have need login or register for voting of answers or question.
Ravi Vishwakarma
28-Sep-2021The Intersect method or operator is used to combine multiple collections or lists into a single collection or list and return common elements from both collections.
Syntax
Example
Output